
#include "Base.h"
#include "EventHandler.h"

namespace CasaEngine
{

Event::~Event() {};


HandlerFunctionBase::~HandlerFunctionBase() {};
void HandlerFunctionBase::exec(const Event* event) {call(event);}


//better use boost::ptr_map instead of std::map
EventHandler::~EventHandler()
{
	Handlers::iterator it = _handlers.begin();
	while(it != _handlers.end())
	{
		delete it->second;
		++it;
	}
	_handlers.clear();
}

void EventHandler::OnFPSChange(const Event* event)
{
	Handlers::iterator it = _handlers.find(TypeInfo(typeid(*event)));
	if(it != _handlers.end())
	{
		it->second->exec(event);
	}
}

} // namespace CasaEngine
